#include <unistd.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <memory>
#include "Thread.hpp"

using std::cout;
using std::endl;
using std::unique_ptr;

class MyThread
:public wd::Thread
{
    void run() override
    {
        // 设置一个随机数种子
        srand(time(nullptr));
        int cnt = 10;

        while(cnt-- > 0)
        {
            // 获取一个100以内的随机数
            int number = rand() % 100;
            cout << "produce a number: " << number << endl;
            sleep(1);
        }
    }
};

int main()
{
    unique_ptr<wd::Thread> thread(new MyThread);
    thread -> start();
    thread -> join();

    cout << "main thread is exiting " << endl;

    return 0;
}


